package com.bvbot.core.session;

import java.math.BigDecimal;

public class BvResponse {

	private final BigDecimal BD_1000 = new BigDecimal("1000");

	private String content;

	public BvResponse(String content) {
		super();
		this.content = content;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	protected String extractAttributValue(String attributeName,
			String totalString) {
		String result = null;
		if (attributeName != null) {
			int idxQtyMatched = totalString.indexOf(attributeName);
			int idxClosingQuotes = totalString.indexOf("\"", idxQtyMatched
					+ attributeName.length() + 2);
			if ((idxQtyMatched >= 0) && (idxClosingQuotes >= 0)) {
				result = totalString.substring(
						idxQtyMatched + attributeName.length() + 2,
						idxClosingQuotes);
			}
		}
		return result;
	}

	protected BigDecimal getValueMultipliedBy1000(String valueAsString) {
		BigDecimal result = null;
		if (valueAsString != null) {
			BigDecimal tmp = new BigDecimal(valueAsString);
			result = tmp.multiply(BD_1000);
		}
		return result;
	}

}
